﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace API.Models.Repository
{
    public class IncomingInvoiceLines_Repository : GenericRepository<PartnerDbContext, V_IncomingInvoiceLines>
    {
        public override IQueryable<V_IncomingInvoiceLines> Find(System.Linq.Expressions.Expression<Func<V_IncomingInvoiceLines, bool>> predicate)
        {
            /// Получить данные
            IQueryable<V_IncomingInvoiceLines> query = _entities.V_IncomingInvoiceLines
                .Include("ITEM");

            /// Фильтрация по заданному условию
            if (predicate != null)
                query = query.Where(predicate);

            //if (session != null)
            //    query = query
            //        .Where(r => r.CUSTOMER_GUID == session.COMPANY_GUID);

            return query.AsQueryable();
        }

        public IQueryable<V_OutgoingInvoiceLines> FindOriginal(System.Linq.Expressions.Expression<Func<V_OutgoingInvoiceLines, bool>> predicate)
        {
            /// Получить данные
            IQueryable<V_OutgoingInvoiceLines> query = _entities.V_OutgoingInvoiceLines
                .Include("ITEM")
                .Include("ITEM.COMPANY");

            /// Фильтрация по заданному условию
            if (predicate != null)
                query = query.Where(predicate);

            return query;
        }
    }
}